<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="div">
<input type="checkbox"  name="op" class="op" value="1" >OP1
<input type="checkbox"  name="op" class="op" value="2" >OP2
</div>
<div class="div">
<input type="checkbox"  name="op" class="op" value="3" >OP3
<input type="checkbox"  name="op" class="op" value="4" >OP4
</div>
<input type="button" value="button" id="btn1">
<table id="tb2" border="1" cellpadding="0">
    <tr>
        <td>ID</td>
        <td>主机名</td>
        <td>IPADD</td>
    </tr>
    <tbody id="tb1">
    <tr>
    </tr>
    </tbody>
</table>
<script>
    let ta1 = document.getElementById("tb1");
    let html = '';
    html += "<tr>";
            html += "<td>"+"<input type=\"checkbox\">"+"</td><td>"+"ip"+"</td><td>"+"Desc"+"</td>";
            html += "</tr>";
    html += "<tr>";
            html += "<td>"+"<input type=\"checkbox\">"+"</td><td>"+"ip"+"</td><td>"+"Desc"+"</td>";
            html += "</tr>";
    ta1.innerHTML = html;
    {#console.log(html);#}
</script>
<script>
         const btn = document.getElementById('btn1');
         console.log(btn);
         btn.onclick=function () {
             const op=document.getElementsByTagName('input');
             console.log(op[0].value);
             console.log(op);
             console.log(op.length);
             console.log(op[0].value);
             const arraylist=[];
             for (let i=0; i < op.length; i++) {
                 if (op[i].checked)
                    arraylist.push(op[i].value);
                    console.log(arraylist);
             }

         }

</script>
</body>
</html>